#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 11592000)
//#use delay(clock = 20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
unsigned char temp_a=0,temp_b=0,pressure=0,load=100;

//#define EEPROM_SDA  PIN_C4
//#define EEPROM_SCL  PIN_C3

#include <24256.c>

//=====================================
void main()
{
printf("Start...\n\r");

/*#include <16F877A.H>
#device ADC=10
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 11592000)
//#use delay(clock = 20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

/*#include<16f877a.h>
#include<stdio.h>
#include<stdlib.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=11592000)*/
//#use delay(clock=20000000)//11592000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

//#define EEPROM_SDA  PIN_C4
//#define EEPROM_SCL  PIN_C3

//#include <24256.c>

//=====================================
//void main()
//{
      delay_ms(300);
printf("Started\n\r");

   //port_b_pullups(true);
//init_ext_eeprom();
   setup_port_A(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   //while(load>96)
   while(1)
   {

      set_adc_channel(0);
      delay_us(10);
      temp_a=Read_ADC();
      printf("Temperature_A=%u\n\r",temp_a);
//      write_ext_eeprom(0,temp_a);
      delay_ms(300);

      set_adc_channel(1);
      delay_us(10);
      temp_b=Read_ADC();
      printf("Temperature_B=%u\n\r",temp_b);
//      write_ext_eeprom(1,temp_b);
      delay_ms(300);

      /*set_adc_channel(2);
      delay_us(10);
      pressure=Read_ADC();
      printf("Pressure=%u\n",pressure);
      write_ext_eeprom(2,pressure);
      delay_ms(300);*/

      set_adc_channel(3);
      delay_us(10);
      load=Read_ADC();
      printf("Load Cell value=%u\n\r",load);
     /* if(load<85)
      {
      printf("over load=%u\n",load);
      }*/
      delay_ms(300);
   }

Printf("\n\n             LAST VALUES ARE\n\r");
Printf("______________________________________________________\n\r");
printf("Temperature_A  %d \n", read_ext_eeprom(0), read_ext_eeprom(0));
printf("Temperature_B %d \n", read_ext_eeprom(1), read_ext_eeprom(1));
//printf(" %c  %d \n", read_ext_eeprom(2), read_ext_eeprom(2));
Printf("\r\n______________________________________________________\n");

//while(1);
}
